<template name="sendcar">
	<!-- 入库交货单列表  -->
	<view class="mypage">

		<view class="cu-bar search bg-white">
			<view class="search-form round">
				<text class="cuIcon-search"></text>
				<input type="text" placeholder="输入单号" v-model="keyword"></input>
			</view>
			<view class="action">
				<button class="cu-btn bg-blue shadow-blur round" @tap="handelSearch">搜索</button>
			</view>
		</view>
		
		<view class="card-list-wrapper">
			<view class="card-list-row radius shadow-warp bg-white margin-top" 
			v-for="(item,index) in orderList" :key="index" @click="openDetail(index)">
				
				<view class="flex-just-between bottom-border top-wrap">
					<text class="text-blue text-bold"> 单号 ：{{ item.BILLNO || '000' }}</text>
					<view class="cu-capsule radius">
						<view class='cu-tag bg-blue sm'>
							<text class='cuIcon-medal'></text>
						</view>
						<view class="cu-tag line-brown sm">
							{{ index+1}}
						</view>
					</view>
				</view>
				
				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">集团：</text>
					<text>{{ item.GROUPNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-red"></text>
					<text class="card-label text-black">组织：</text>
					<text>{{ item.ORGNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-orange"></text>
					<text class="card-label text-black">部门：</text>
					<text> {{ item.DEPTNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-green"></text>
					<text class="card-label text-black">供应商：</text>
					<text>{{ item.BILLMAKER || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-blue"></text>
					<text class="card-label text-black">物料：</text> 
					<text>{{ item.MATERIALNAME || '' }}</text>
				</view>
				<view class="card-list-row-1">
					<text class="cuIcon-title text-gray"></text>
					<text class="card-label text-black">日期：</text> 
					<text>{{ item.BILLDATE || '' }}</text>
				</view>
				<!-- <view class="card-list-row-1">
					<text class="cuIcon-title text-orange"></text>
					<text>规格：{{ '52.5R '}} </text> 
					<text class="text-blue">&emsp; {{ '500吨'}}&emsp;</text> |
					<text class="text-red">&emsp;￥{{ '32.00'}}</text>
				</view> -->
		
				<!-- <view class="flex-just-between top-border margin-top btn-wrap">
					<button class="cu-btn round lines-gray" >出库</button>
					<button class="cu-btn round lines-gray" >移位</button>
				</view> -->
				
				
			</view>
		
		</view>
		
	</view>

</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex'
	import api from '@/common/api.js'
	import utils from '@/common/util.js'
	let _self, page=1, total=1, pageTitle,type,requeryURL;
	let query = {
			"category":"",
			"page":1,
			"rows":5,
			"sidx":"",
			"sord":"",
			"queryJson":{},
			"userId":"",
			"account":"admin"
	}
	let queryJson = {ISFINISH:0,BILLSTATUS:1,DR:0};
	export default {
		computed: mapState(['userInfo']),
		data() {
			return {
				orderList: [],
				keyword:''
			};
		},
		onLoad(params) {
			_self = this 
			console.log(params)
			page = 1;
			total = 1 ;
			pageTitle = params.pageTitle
			// query.category = params.sqlTbName
			query.account = this.userInfo.Account
			query.userId = this.userInfo.UserId
			requeryURL =  '/api/APPCommon/GetSaleCommitList/'
			this.getNewsList();
		},
		// 导航栏点击
		onNavigationBarButtonTap(e) {  
				console.log("点击了自定义按钮");
				console.log(e);
		},  
		//下拉刷新
		onPullDownRefresh : function(){
			// 重置分页及数据
			page = 1;
			total = 1 ;
			this.getNewsList();
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
			uni.showToast({"title":"数据已刷新", icon:"none"});
		},
		// 加载更多
		onReachBottom : function(){
			this.getNewsList();
		},
		methods:{
			handelSearch(){
				console.log(_self.keyword);
				queryJson.BILLNO = _self.keyword ;
				page = 1;
				total = 1 ;
				this.orderList = [] ;
				this.getNewsList();
			},
			getNewsList(){
				if( page>total ){return uni.showToast({
					icon:'none',
					title:'没有数据了。'
				})}
				query.page = page ;
				query.queryJson = JSON.stringify(queryJson);
				this.axios({
					url: URL ,
					data: query ,
					isLoading: 1
				}).then(res=>{
					let { Result } = res ;
					if( page == 1){
						_self.orderList = Result.rows
						if(Result.rows.length==0) {
							utils.tips('暂无数据！');
						}
						_self.setPageTitle(pageTitle+'列表('+Result.records+')')
					}else{
						_self.orderList = _self.orderList.concat(Result.rows)
					}
					total = Result.total
					page++
				})
			},
			
			setPageTitle(d){
				uni.setNavigationBarTitle({
				    title: d
				});
			},
			
			openDetail(e){
				 console.log(e);
				let url = '/pages/tab01/d-inbound/detail?id=' 
				  + _self.orderList[e].BILLNO +'&dbt='
					+ query.category +'&item='+encodeURIComponent(JSON.stringify(_self.orderList[e]));
				uni.navigateTo({
					url:  url 
				})
			}
		}
	}
</script>

<style scoped>
	
	.card-list-wrapper {
		width: 710upx;
		height: 100upx;
		margin: 0 auto;
	}

	.card-list-row {
		padding: 20upx;
	}

	.card-list-row-1 {
		padding: 10upx 0;
	}
	.card-label{
		display: inline-block;
		width: 150upx;
	}
	.top-border{
		border-top: 1upx solid rgba(0,0,0,.1);
	}
	.top-wrap{
		padding-bottom: 20upx;
		margin-bottom: 20upx;
	}
	.bottom-border{
		border-bottom: 1upx solid rgba(0,0,0,.1);
	}
	.btn-wrap{
		padding-top: 20upx;
	}
</style>
